<template>
  <div>
    <custom-table
      :columns="tableColumns"
      :action-url="'/pole/info/list'"
      :has-search="true"
      :search-data="searchData"
      :has-select="true"
      :heard-operation="heardOperation"
      :form-option-items="formOptionItems"
    >
      <!-- 出口入口 -->
      <template #poleStatus="{row}">
        {{ row.poleStatus==='0'?'正常':'异常' }}
      </template>
      <!-- 一体杆类型 -->
      <template #poleType="{row}">
        {{ row.poleType==='entrance'?'入口':'出口' }}
      </template>
    </custom-table>
  </div>
</template>

<script>
import CustomTable from '@/components/CustomTable2.vue'

export default {
  components: { CustomTable },
  data() {
    return {
      searchData: [
        { label: '一体杆名称', type: 'input', name: 'poleName' },
        { label: '一体杆编号', type: 'input', name: 'poleNumber' },
        { label: '运行状态', type: 'select', name: 'poleStatus', options: [{ label: '全部', value: ' ' }, { label: '正常', value: '0' }, { label: '异常', value: '1' }] }
      ],
      tableColumns: [
        { label: '一体杆名称', prop: 'poleName' },
        { label: '一体杆编号', prop: 'poleNumber' },
        { label: '一体杆IP', prop: 'poleIp' },
        { label: '安装区域', prop: 'areaName' },
        { label: '一体杆类型', prop: 'poleType', custom: true }, // entrance export center
        { label: '运行状态', prop: 'poleStatus', custom: true }, // 0 1
        { label: '操作', prop: 'operate', operations: [
          { label: '编辑', handler: { name: 'edit', detailUrl: '', url: '/pole/info' }},
          { label: '删除', handler: { name: 'delete', url: '/pole/info/', title: '是否确定删除一体杆?' }}
        ] }
      ],
      heardOperation: [
        { name: 'add', title: '添加一体杆', handler: { url: '/pole/info' }},
        { name: 'delete', title: '批量删除', handler: { url: '/pole/info/' }}
      ],
      formOptionItems: [
        { type: 'text', label: '一体杆名称', name: 'poleName' },
        { type: 'text', label: '一体杆编号', name: 'poleNumber', edit: { prop: { disabled: 'true' }}},
        { type: 'text', label: '一体杆IP', name: 'poleIp', rule: { pattern: /^(\d{1,3}\.){3}\d{1,3}$/, message: '请输入正确的IP', trigger: 'blur' }},
        { type: 'select', label: '关联区域', name: 'areaId', handler: { label: 'name', value: 'id', url: '/park/all/enterprise' }},
        { type: 'select', label: '一体杆类型', name: 'poleType',
          options: [
            { value: 'entrance', label: '入口' }, { value: 'export', label: '出口' }
          ]
        }
      ]
    }
  }
}
</script>

<style>
</style>
